GH-31374: [C++] Prevent strptime from normalizing invalid dates - #50747
Open
fallintoplace wants to merge 1 commit into
Open
GH-31374: [C++] Prevent strptime from normalizing invalid dates#50747fallintoplace wants to merge 1 commit into
fallintoplace wants to merge 1 commit into
Conversation
|
|
fallintoplace
force-pushed
the
fix/strptime-invalid-calendar-dates
branch
from
July 30, 2026 17:55
047180d to
9e2fca7
Compare
|
|
fallintoplace
force-pushed
the
fix/strptime-invalid-calendar-dates
branch
from
July 30, 2026 17:59
9e2fca7 to
d4ec27c
Compare
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
After
strptimepopulates atm, Arrow converts its calendar fields directly tosys_days. Sincesys_daysnormalizes invalid dates, an input such as1999-02-30becomes March 2 instead of failing to parse.What changes are included in this PR?
Validate the parsed
year_month_daybefore converting it tosys_days. Invalid dates now use the existing parse-failure path.The regression test covers invalid month lengths and leap days. It also verifies the exact timestamps produced for valid leap-year and month-end boundaries.
Are these changes tested?
Yes. The regression test fails against the original implementation and passes with this change. Both the focused
TimestampParser.StrptimeParser*tests and the completearrow-utility-testsuite pass locally.Are there any user-facing changes?
Invalid calendar dates passed to
strptimenow fail instead of producing normalized timestamps. Valid dates retain their existing results.This PR contains a "Critical Fix". Invalid input could previously produce an incorrect timestamp.